<?php
/**
 * Created by 胡祥能 on 2018/1/4.
 *  email：huxiangneng@jiuletech.com
 */

namespace App\Http\Middleware;

use App\User;
use Closure;

class RedirectLogin
{
    /**自定义用户验证中间件
     * @param $request
     * @param Closure $next
     * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|mixed
     */
    public function handle($request, Closure $next)
    {
        if(!$request->session()->has(User::SESSION_KEY)){
            return redirect('/login');
        }

        return $next($request);
    }
}